<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Connecting to PostgreSQL databases</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.pdo-pgsql.html">PostgreSQL (PDO)</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="pdo.pgsqllobcreate.html">PDO::pgsqlLOBCreate</a></div>
 <div class="up"><a href="ref.pdo-pgsql.html">PostgreSQL (PDO)</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="ref.pdo-pgsql.connection" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">PDO_PGSQL DSN</h1>
    <p class="verinfo">(PECL PDO_PGSQL &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">PDO_PGSQL DSN</span> &mdash; <span class="dc-title">Connecting to PostgreSQL databases</span></p>

   </div>

   <div class="refsect1 description" id="refsect1-ref.pdo-pgsql.connection-description">
    <h3 class="title">说明</h3>
    <p class="para">
     The PDO_PGSQL Data Source Name (DSN) is composed of the following elements, delimited by spaces or semicolons:
     <dl>

      
       <dt>
DSN prefix</dt>

       <dd>

        <p class="para">
        The DSN prefix is <strong class="userinput"><code>pgsql:</code></strong>.
        </p>
       </dd>

      
      
       <dt>
<em>host</em></dt>

       <dd>

        <p class="para">
         The hostname on which the database server resides.
        </p>
       </dd>

      
      
       <dt>
<em>port</em></dt>

       <dd>

        <p class="para">
         The port on which the database server is running.
        </p>
       </dd>

      
      
       <dt>
<em>dbname</em></dt>

       <dd>

        <p class="para">
         The name of the database.
        </p>
       </dd>

      
      
       <dt>
<em>user</em></dt>

       <dd>

        <p class="para">
         The name of the user for the connection. If you specify the user name
         in the DSN, PDO ignores the value of the user name argument in the
         PDO constructor.
        </p>
       </dd>

      
      
       <dt>
<em>password</em></dt>

       <dd>

        <p class="para">
         The password of the user for the connection. If you specify the
         password in the DSN, PDO ignores the value of the password argument
         in the PDO constructor.
        </p>
       </dd>

      

     </dl>

    </p>
    <blockquote class="note"><p><strong class="note">Note</strong>: 
     <p class="para">
      The <em>bytea</em> fields are returned as streams.
     </p>
    </p></blockquote>
   </div>

   <div class="refsect1 examples" id="refsect1-ref.pdo-pgsql.connection-examples">
    <h3 class="title">范例</h3>
    <p class="para">
     <div class="example" id="example-959">
      <p><strong>Example #1 PDO_PGSQL DSN examples</strong></p>
      <div class="example-contents"><p>
       The following example shows a PDO_PGSQL DSN for connecting to
       a PostgreSQL database:
       <div class="example-contents"><div class="cdata"><pre>
pgsql:host=localhost;port=5432;dbname=testdb;user=bruce;password=mypass
</pre></div>
       </div>

      </p></div>
     </div>
    </p>
   </div>

  </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.pdo-pgsql.html">PostgreSQL (PDO)</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="pdo.pgsqllobcreate.html">PDO::pgsqlLOBCreate</a></div>
 <div class="up"><a href="ref.pdo-pgsql.html">PostgreSQL (PDO)</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
